package com.mall.order.service.impl;

import com.mall.order.entity.OrderEntity;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.common.utils.PageUtils;
import com.common.utils.Query;

import com.mall.order.dao.OrderItemDao;
import com.mall.order.entity.OrderItemEntity;
import com.mall.order.service.OrderItemService;


@Service("orderItemService")
public class OrderItemServiceImpl extends ServiceImpl<OrderItemDao, OrderItemEntity> implements OrderItemService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<OrderItemEntity> page = this.page(
                new Query<OrderItemEntity>().getPage(params),
                new QueryWrapper<OrderItemEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 需要开启@EnableRabbitMQ
     *   * @RabbitListener(queues = {"hello-queue"})
     *      * queues:需要监听的队列
     *      *
     *  @RabbitListener 类+方法上
     * @RabbitHandler 只能标注在方法上
     * @param message  消息头
     * @param orderEntity 发送时序列化的对象可以直接反序列化
     * @param channel 传输数据的通道
     */
    @RabbitListener(queues = {"hello-queue"})
    public void receiveMessage(Message message, OrderEntity orderEntity, Channel channel){
        System.out.println("接收到消息内容" + message);
        System.out.println("aaaaaaaa" + orderEntity);
    }
}